package com.xliee.common.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册TestInterceptor拦截器
        InterceptorRegistration registration = registry.addInterceptor(new MyInterceptor());
        //所有路径都被拦截
        registration.addPathPatterns("/**");
        //添加不拦截路径
        registration.excludePathPatterns(
                "/register",    //注册页
                "/doRegister",  //注册实现
                "/login",       //登录页
                "/doLogin",     //登录实现
                "/readme",      //用户协议
                "/email",       //邮件页
                "/doEmail",     //发送邮件
                "/forgetPass",  //重置密码页面
                "/resetPass",   //重置密码实现
                "/images/**",
                "/libs/**",
                "/scss/**",
                "/**/*.js",
                "/**/*.css"
        );
    }

}
